#!/bin/bash

export CROSSPATH=/opt/arm-hisiv300-linux/bin
export PATH=${PATH}:${CROSSPATH}

export TARGET=arm-hisiv300-linux-uclibcgnueabi
export CROSS=arm-hisiv300-linux-uclibcgnueabi
export BUILD=x86_64-pc-linux-gnu

export CROSSPREFIX=${CROSS}-

export STRIP=${CROSSPREFIX}strip
export CXX=${CROSSPREFIX}g++
export CC=${CROSSPREFIX}gcc
export LD=${CROSSPREFIX}ld
export AS=${CROSSPREFIX}as
export AR=${CROSSPREFIX}ar

SCRIPT_DIR=$(cd `dirname $0` && pwd)
cd $SCRIPT_DIR

cd snapshot || exit 1

make clean
make || exit 1

mkdir -p ../_install/bin || exit 1

cp ./imggrabber ../_install/bin || exit 1
mkdir -p ../_install/etc/wm_res/low/
cp ./wm_res/low/* ../_install/etc/wm_res/low/ || exit 1
mkdir -p ../_install/etc/wm_res/high/
cp ./wm_res/high/* ../_install/etc/wm_res/high/ || exit 1

${STRIP} ../_install/bin/* || exit 1
